home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
telecomm
/
zmdm_src.arc
/
RZ.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-06-26
|
28KB
|
1,454 lines
/*
* ACKNOWLEDGEMENTS
*
* ZMDM was derived from rz/sz for Unix posted by
* Chuck Forsberg (...!tektronix!reed!omen!caf ). We
* thank him for his excellent code, and for giving
* us permission to use and distribute his code and
* documentation.
*
* Atari St version by:
* Jwahar Bammi
* usenet: mandrill!bammi@{decvax,sun}.UUCP
* csnet: bammi@mandrill.ces.CWRU.edu
* arpa: bammi@mandrill.ces.CWRU.edu
* CompuServe: 71515,155
*/
#include "config.h"
#define RVERSION "rz 1.14 01-15-87"
#define RSTVERSION "rz 1.01 03-07-87"
#define OS "Unix V7/BSD"
/* #define RDEBUG */ /* a lot of debugging garb */
/*
* ATARI ST series implementation notes:
*
* - the following command line options were removed as they
* were either not applicable to the ST environment or
* were not deemed reasonable (by me - ofcourse).
* 1 Not Applicable here as we have a seperate
* serial port.
* 7 In this day and age? Forget it, get another m/c.
* a/b Ascii/Binary - the receive mode (if not
* over-ridden by the sender) is automatically
* selected depending on the extention given
* in the incoming file name. This idea was
* present in earlier rz/sz, i wonder why such
* a convenient feature was dropped (Chuck ??).
* This feature is relevant to ZMODEM only in rz,
* as the sender determines the file mode in
* XMODEM/YMODEM transfers.
* B Note that `B' has a special meaning.
* Specifying -B will force override to
* binary mode for each incoming file. Useful
* when doing St-to-St transfers.
* D There is no /dev/null on the ST's
* u not applicable to TOS. Upper and lower
* case file names are the same. All the
* applicable routines like uncap() and
* IsAnyLower() were zapped.
*
* - The [-][v]rzCOMMAND style of invocation was dropped
* as there is no good way to do pipes without the
* microRtx kernal. All references to Pipe and popen()
* were zapped.
* - Verbose is always set to 2 by automatically, as we know that
* stdout != stderr. This can be overridden
* by specifying -q to ensure that Verbose = 0
* - The idea of a PUBDIR and Restricted paths in the origonal
* code was dropped totally as it is not applicable
* to the single owner ST environment. 1 man 1 machine.
* - CRCTABLE is default always, hey we have plenty of memory!.
* - LOGFILE renamed to 'rzlog/szlog' as we don't always have
* a meaningful environment to pick up TMPDIR from (like when
* running from the desktop).
* - When a subdirectory in an incoming path name is not
* present it is created.
* - The file mode transmitted is 0S00 where S is derived from
* the Read/Write attribute of the file on the ST
* - When a file mode is received, only the owner bits are
* are checked. If it was read only (r--) on the Unix sytem
* then it is given read only attribute on the ST, read-write
* otherwise.
* - Of course all the I/O was completely redone on the ST.
* - You will find two versions of VARARGS routines like log,
* one that takes int args, and the other that takes long
* (address) args, since sizeof(int) != sizeof(long)
* and sizeof(int) != sizeof(pointer) on the ST.
*
* ST v1.01
* added support for 32 bit CRC's for Zmodem ++jrb
*
* ST v1.2
* added -B ++jrb
* added all the recursive stuff
* added remote
*/
/*% cc -DNFGVMIN -DCRCTABLE -K -O % -o rz; size rz
*
* rz.c By Chuck Forsberg
*
* cc -O rz.c -o rz USG (3.0) Unix
* cc -O -DV7 rz.c -o rz Unix V7, BSD 2.8 - 4.3
*
* ln rz rb For either system
*
* ln rz /usr/bin/rzrmail For remote mail. Make this the
* login shell. rzrmail then calls
* rmail(1) to deliver mail.
*
* define CRCTABLE to use table driven CRC
*
* Unix is a trademark of Western Electric Company
*
* A program for Unix to receive files and commands from computers running
* Professional-YAM, PowerCom, YAM, IMP, or programs supporting XMODEM.
* rz uses Unix buffered input to reduce wasted CPU time.
*
* Iff the program is invoked by rzCOMMAND, output is piped to
* "COMMAND filename"
*
* Some systems (Venix, Coherent, Regulus) may not support tty raw mode
* read(2) the same way as Unix. ONEREAD must be defined to force one
* character reads for these systems. Added 7-01-84 CAF
*
* Alarm signal handling changed to work with 4.2 BSD 7-15-84 CAF
*
* NFGVMIN Added 1-13-85 CAF for PC-AT Xenix systems where c_cc[VMIN]
* doesn't seem to work (even though it compiles without error!).
*
* USG UNIX (3.0) ioctl conventions courtesy Jeff Martin
*/
#include "zmdm.h"
#include "common.h"
#include "zmodem.h"
static unsigned long SaveIntr;
#ifndef Vsync /* Atari forgot these in osbind.h */
#define Vsync() xbios(37)
#endif
#ifndef Supexec
/* Some versions of osbind don't define Supexec */
#define Supexec(X) xbios(38,X)
#endif
#if (MWC || MANX)
extern FILE *fopen();
#else
extern FILE *fopen(), *fopenb();
#endif
#ifndef STANDALONE
#define RETURN return
#else
int bibis() {} /* dummy */
#endif
static long start_time;
/* called by simulated signal interrupt or terminate to clean things up */
bibi(n)
int n;
{
if (Zmodem)
zmputs(Attn);
canit(); mode(0);
fprintf(STDERR, "\r\nrz: caught signal %d; exiting", n);
if (fout != -1)
{
if (stfclose(fout) != 0)
{
fprintf(STDERR, "\r\nfile close ERROR\n");
}
fout = (-1);
}
#ifdef RDEBUG
if (logf != (FILE *)NULL)
fclose(logf);
#endif
aexit(128+n);
}
#ifdef STANDALONE
main(argc, argv)
#else
dorz(argc, argv)
#endif /* STANDALONE */
int argc;
char **argv;
{
register char *cp;
register int npats;
char **patts;
int exitcode;
#ifdef STANDALONE
#ifdef MWC
extern char *lmalloc();
#endif
/* Set up Dta */
Fsetdta(&statbuf);
/* Get screen rez */
rez = Getrez();
drv_map = Drvmap();
#if (MWC || MANX)
#ifndef DYNABUF
#ifdef MWC
if((bufr = (unsigned char *)lmalloc((unsigned long)BBUFSIZ))
== (unsigned char *)NULL)
#else
if((bufr = (unsigned char *)Malloc((unsigned long)BBUFSIZ))
== (unsigned char *)NULL)
#endif
#else
if((bufr = dalloc()) == (unsigned char *)NULL)
#endif /* DYNABUF */
{
#ifdef REMOTE
Bauxws("Sorry, could not allocate enough memory\r\n");
#else
Bconws("Sorry, could not allocate enough memory\r\n");
#endif
Pterm(4);
}
#else /* MWC || MANX */
#ifdef DYNABUF
if((bufr = dalloc()) == (unsigned char *)NULL)
{
#ifdef REMOTE
Bauxws("Sorry, could not allocate enough memory\r\n");
#else
Bconws("Sorry, could not allocate enough memory\r\n");
#endif
Pterm(5);
}
#endif /* DYNABUF */
#endif /* MWC || MANX */
#ifndef REMOTE
STDERR = stderr;
#else
#ifndef DLIBS
if((STDERR = fopen("aux:", "rw")) == (FILE *)NULL)
{
Bauxws("Could not Open Aux Stream for Stderr\r\n");
finish();
}
setbuf(STDERR, (char *)NULL);
#else
STDERR = stdaux;
#endif /* DLIBS */
#endif /* REMOTE */
{
int speed;
speed = getbaud();
Baudrate = BAUD_RATE(speed);
SetIoBuf();
Rsconf(speed, 0,-1,-1,-1,-1);
Vsync(); Vsync();
}
#endif /* STANDALONE */
SendType = 0;
Rxtimeout = 100;
exitcode = 0;
initz();
#ifndef STANDALONE
chkinvok(argv[0]); /* if called as 'rb' set flag */
#else
Progname = "rz";
#endif
npats = 0;
SaveIntr = Setexc(0x0102, -1L);
BusErr = Setexc(2, -1L);
AddrErr = Setexc(3, -1L);
vdebug = 0;
while (--argc)
{
cp = *++argv;
if (*cp == '-')
{
while( *++cp)
{
switch(*cp)
{
case '+':
Lzmanag = ZMAPND; break;
case 'B':
ForceBinary=TRUE; break;
case 'c':
Crcflg=TRUE; break;
case 'p':
Lzmanag = ZMPROT; break;
case 'q':
Quiet=TRUE; Verbose=0; break;
case 't':
if (--argc < 1) {
rusage();
RETURN(1);
}
Rxtimeout = atoi(*++argv);
if (Rxtimeout<10 || Rxtimeout>1000)
{
rusage();
RETURN(1);
}
break;
case 'v':
++Verbose; break;
default:
rusage();
RETURN(1);
}
}
}
else if ( !npats && argc>0)
{
if (argv[0][0])
{
npats=argc;
patts=argv;
}
}
}
if (npats > 1)
{
rusage();
RETURN(1);
}
#ifdef RDEBUG
if (Verbose > 2)
{
if ((logf